<template>
    <div class="p-2">
        <transition :enter-active-class="proxy?.animate.searchAnimate.enter"
            :leave-active-class="proxy?.animate.searchAnimate.leave">
            <searchrevealing>
                <el-tabs v-model="activeTab">
                    <el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="104px">
                        <el-form-item label="商品编码/69码" prop="content">
                            <el-input v-model="queryParams.content" placeholder="请输入" clearable style="width: 220px"
                                @keyup.enter="handleQuery" />
                        </el-form-item>
                        <el-form-item label="类目" prop="categoryIdList">
                            <el-cascader v-model="queryParams.categoryIdList" clearable :options="categoryProps"
                                filterable collapse-tags :props="props" style="width: 220px" @change="handleChange"
                                placeholder="请选择类目" ref="categoryRef" />
                        </el-form-item>
                        <el-form-item label="供应商名称" prop="supplierName">
                            <el-select v-model="queryParams.supplierName" placeholder="请选择供应商" clearable filterable
                                v-selectLoad="selectLoad" :teleported="false" :fit-input-width="true" remote
                                :remote-method="searchQuery" class="supplierSelect" style="width: 220px"
                                :loading="supplierQueryLoading" @clear="handleClear">
                                <el-option v-for="dict in supplierNameOptions" :key="dict.value" :label="dict.label"
                                    :value="dict.value">
                                </el-option>
                                <template v-if="supplierLoading">
                                    <div class="supplierSelect_icon">
                                        <el-icon class="el-select-loading__icon">
                                            <Loading />
                                        </el-icon>
                                        <span class="el-select-loading__tips">{{ "正在加载" }}</span>
                                    </div>
                                </template>
                                <template #loading>
                                    <svg class="circular" viewBox="0 0 50 50">
                                        <circle class="path" cx="25" cy="25" r="20" fill="none" />
                                    </svg>
                                </template>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="商品状态" prop="auditStatus">
                            <el-select style="width: 220px" v-model="queryParams.auditStatus" placeholder="请选择"
                                filterable clearable>
                                <el-option v-for="item in hm_product_status" :key="item.value" :label="item.label"
                                    :value="item.value"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="创建时间" prop="startTime">
                            <el-date-picker value-format="YYYY-MM-DD" v-model="startTime" type="daterange"
                                @change="pickerChange" start-placeholder="开始时间" end-placeholder="结束时间" clearable
                                style="width: 220px" />
                        </el-form-item>
                        <el-form-item label="商品名称" prop="styleName">
                            <el-input v-model="queryParams.styleName" placeholder="请输入商品名称" clearable
                                style="width: 220px" @keyup.enter="handleQuery" />
                        </el-form-item>
                        <el-form-item label="品牌名称" prop="brandName">
                            <el-input v-model="queryParams.brandName" placeholder="请输入品牌名称" clearable
                                style="width: 220px" @keyup.enter="handleQuery" />
                        </el-form-item>
                        <el-form-item label="部门类型" prop="recruiterDeptId">
                            <el-select v-model="queryParams.recruiterDeptId" placeholder="请选择部门类型" clearable filterable
                                @change="departmentTypeChange" style="width: 220px">
                                <el-option v-for="dict in departmentTypeList" :key="dict.deptId" :label="dict.deptName"
                                    :value="dict.deptId" />
                            </el-select>
                        </el-form-item>
                        <el-form-item label="部门名称" prop="recruiterDeptIds">
                            <el-select v-model="queryParams.recruiterDeptIds" placeholder="请选择部门名称" clearable filterable
                                @change="deptChange" style="width: 220px">
                                <el-option v-for="dict in deptList" :key="dict.deptId" :label="dict.deptName"
                                    :value="dict.deptId" />
                            </el-select>
                        </el-form-item>
                        <el-form-item label="人员名称" prop="recruiterUserId">
                            <el-select v-model="queryParams.recruiterUserId" placeholder="请选择人员名称" clearable filterable
                                style="width: 220px">
                                <el-option v-for="dict in recruiterList" :key="dict.userId" :label="dict.nickName"
                                    :value="dict.userId" />
                            </el-select>
                        </el-form-item>
                        <el-form-item label="合同状态" prop="contractStatus">
                            <el-select style="width: 220px" v-model="queryParams.contractStatus" placeholder="请选择"
                                filterable clearable>
                                <el-option v-for="item in contractList" :key="item.value" :label="item.label"
                                    :value="item.value"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="选品部门" prop="coreIdList">
                            <el-select style="width: 220px" v-model="queryParams.coreIdList" placeholder="请选择" clearable
                                filterable multiple>
                                <el-option v-for="dict in anchorList" :key="dict.deptId" :label="dict.deptName"
                                    :value="dict.deptId"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="直播类型" prop="liveTypeList">
                            <el-select style="width: 220px" v-model="queryParams.liveTypeList" placeholder="请选择"
                                filterable clearable multiple>
                                <el-option v-for="item in liveTypeList" :key="item.value" :label="item.label"
                                    :value="item.value"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="核价通过时间" prop="pricingTime">
                            <el-date-picker value-format="YYYY-MM-DD" v-model="pricingTime" type="daterange"
                                @change="pricingPickerChange" start-placeholder="开始时间" end-placeholder="结束时间" clearable
                                style="width: 220px" />
                        </el-form-item>
                        <el-form-item label="选品时间" prop="selectionTime">
                            <el-date-picker value-format="YYYY-MM-DD" v-model="selectionTime" type="daterange"
                                @change="selectionPickerChange" start-placeholder="开始时间" end-placeholder="结束时间"
                                clearable style="width: 220px" />
                        </el-form-item>
                        <el-form-item label="跳过物流" prop="skip">
                            <el-select style="width: 220px" v-model="queryParams.skip" placeholder="请选择" filterable
                                clearable>
                                <el-option v-for="item in skipList" :key="item.value" :label="item.label"
                                    :value="item.value"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-form>
                    <div class="form_button">
                        <el-button type="primary" @click="handleQuery" :loading="loading">查询</el-button>
                        <el-button @click="resetQuery" :loading="loading">重置</el-button>
                    </div>
                </el-tabs>
            </searchrevealing>
        </transition>
        <el-card shadow="never">
            <template #header>
                <el-row :gutter="10" class="mb8">
                    <el-col :span="1.5">
                        <el-button type="primary" @click="addProduct('添加商品')">商品新增</el-button>
                    </el-col>
                    <el-col :span="1.5">
                        <el-button type="primary" :loading="buttonLoading" plain @click="handleOperate('确认收货')"
                            :disabled="ids.length === 0">确认收货</el-button>
                    </el-col>
                    <el-col :span="1.5">
                        <el-button type="primary" :loading="buttonLoading" plain @click="handleOperate('上架')"
                            :disabled="ids.length === 0">上架</el-button>
                    </el-col>
                    <el-col :span="1.5">
                        <el-button type="primary" :loading="buttonLoading" plain @click="handleOperate('发起初审')"
                            :disabled="ids.length === 0">发起初审</el-button>
                    </el-col>
                    <el-col :span="1.5">
                        <el-button type="primary" :loading="buttonLoading" plain @click="handleOperate('入库')"
                            :disabled="ids.length === 0">入库</el-button>
                    </el-col>
                    <el-col :span="1.5">
                        <el-button type="danger" :loading="buttonLoading" plain @click="handleOperate('下架')"
                            :disabled="ids.length === 0">下架</el-button>
                    </el-col>
                    <right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :name="'招商部商品管理'"
                        @updateColumn="getColmun"></right-toolbar>
                </el-row>
            </template>
            <el-table v-loading="loading" row-key="id" :data="tableData" @selection-change="handleSelectionChange"
                border @header-dragend="dragEnd">
                <el-table-column type="selection" width="55" align="center" />
                <el-table-column v-for="(item, index) in commodityManage" :key="index" :label="item.label"
                    align="center" :prop="item.prop" show-overflow-tooltip :fixed="item.fixed" :width="item.width">
                    <template #default="scope">
                        <image-preview v-if="item.prop == 'productImage'" :src="scope.row.productImage" :width="50"
                            :height="50" />
                        <div v-if="item.prop == 'hmMechanismsList'">
                            <div>{{ computedMechanism(scope.row.hmMechanismsList && scope.row.hmMechanismsList[0] ||
                                null,
                                '一') }}
                            </div>
                            <div>{{ computedMechanism(scope.row.hmMechanismsList && scope.row.hmMechanismsList[1] ||
                                null,
                                '二') }}
                            </div>
                            <div>{{ computedMechanism(scope.row.hmMechanismsList && scope.row.hmMechanismsList[2] ||
                                null,
                                '三') }}
                            </div>
                        </div>
                        <div v-if="item.prop == 'supplierName'">
                            <div class="supplierName">
                                <img :src="visaExemption" class="visaExemption" v-if="scope.row.bigBrandStatus == 1" />
                                <div class="supplierName_text">{{ scope.row.supplierName }}</div>
                            </div>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column label="操作" align="center" fixed="right" width="150">
                    <template #default="scope">
                        <el-button link size="small" type="primary"
                            @click="handleInfo(scope.row, '查看详情')">查看详情</el-button>
                        <div class="flex">
                            <el-button link size="small" type="primary"
                                @click="handleInfo(scope.row, '编辑商品')">修改</el-button>
                            <el-dropdown v-if="scope.row.auditStatus != '-2' && scope.row.auditStatus != '3'">
                                <span class="el-dropdown-link" style="display: flex;">
                                    更多
                                    <el-icon class="el-icon--right">
                                        <arrow-down />
                                    </el-icon>
                                </span>
                                <template #dropdown>
                                    <el-dropdown-menu>
                                        <el-dropdown-item
                                            v-for="(item, index) in statusFormat2(auditStatusButtonById(scope.row.auditStatus), scope.row.trackingNumber, scope.row)"
                                            :key="index" @click="handleChangeStatus(scope.row, item)">{{ item
                                            }}</el-dropdown-item>
                                    </el-dropdown-menu>
                                </template>
                            </el-dropdown>
                        </div>
                    </template>
                </el-table-column>
            </el-table>
            <pagination v-show="tableTotal > 0" :total="tableTotal" v-model:page="queryParams.pageNum"
                v-model:limit="queryParams.pageSize" @pagination="paginationChange" />
        </el-card>

        <el-drawer v-model="isAddDrawer" :title="AddFormTitle" direction="rtl" size="70%" :before-close="handleClose"
            :close-on-click-modal="false">
            <AddForm v-if="isAddDrawer" @onSubmit="AddFormSubmit" :title="AddFormTitle" :AddFormId="AddFormId"
                :disabledName="disabledName" />
        </el-drawer>
        <!-- 已邮寄 -->
        <mailed :expressDeliveryDialogVisible="expressDeliveryDialogVisible" :id="productId"
            @close="expressDeliveryDialogVisible = false" @submit="expressDeliverySubmit">
        </mailed>
        <!-- 主播选品 -->
        <el-drawer v-model="anchorSelectionVisible" title="主播选品" direction="rtl" size="30%"
            :before-close="anchorSelectionHandleClose" :close-on-click-modal="false">
            <anchorSelection :id="productId" v-if="anchorSelectionVisible" @close="anchorSelectionHandleClose"
                @submit="anchorSelectionHandleChange" :isChange="isChangeList" @onChangeSubmit="onChangeSubmit">
            </anchorSelection>
        </el-drawer>
        <!-- 打印条码 -->
        <print ref="printRef" />
        <!-- 送审 -->
        <qualificationsDialog :qualificationsDialogVisible="qualificationsFlag" :id="productId"
            @close="qualificationsFlag = false" @submit="qualificationsFlagSubmit">
        </qualificationsDialog>
        <!-- 无合同审批 -->
        <noContractApprovalDialog :noContractApprovalDialogVisible="noContractApprovalFlag" :id="productId"
            @close="noContractApprovalFlag = false" @submit="noContractApprovalSubmit">
        </noContractApprovalDialog>
        <!-- 变价审核 -->
        <el-drawer v-model="mechanismPriceChangeVisible" title="变价审批" direction="rtl" size="50%"
            :before-close="mechanismPriceChangeHandleClose" :close-on-click-modal="false">
            <mechanismPriceChange v-if="mechanismPriceChangeVisible" @close="mechanismPriceChangeHandleClose"
                @submit="mechanismPriceChangeHandleChange" :isChangeList="mechanismPriceChangeList">
            </mechanismPriceChange>
        </el-drawer>
        <!--      物流信息-->
        <el-drawer v-model="logisticsInfoVisible" title="查看物流信息" direction="rtl" size="50%"
            :close-on-click-modal="false" icon="">

            <div class="logisticsContent">
                <div>快递公司: {{ shippingCompany }}</div>
                <div style="margin-top: 20px; margin-bottom: 50px">快递单号: {{ trackingNumber }}</div>
                <div style="overflow-y: auto;">
                    <el-steps direction="vertical">
                        <el-step v-for="(item, index) in logisticsTraceDetailList" :key="index">
                            <template #icon>
                                <div class="custom-icon" :class="{ 'active': 0 === index }"></div>
                            </template>
                            <template #title>
                                <div :style="{ 'color': item.logisticsStatus === 'SIGN' ? '#1890FF' : 'black' }">
                                    <span style="margin-right: 10px;font-size: 20px">{{
                                        statusFormat(item.logisticsStatus) }}</span>
                                    <span>{{ formatTimestamp(item.time) }}</span>
                                </div>
                            </template>
                            <template #description>
                                <div v-html="highlightPhoneNumbers(item.desc)"
                                    style="margin-bottom: 20px; color: black"></div>
                            </template>
                        </el-step>
                    </el-steps>
                </div>
                <div class="submitFooter">
                    <el-button type="info" style="margin-right: 30px" @click="closeLogistics">关闭</el-button>
                    <el-button type="primary" v-if="confirmReceiptStatus" @click="handleReceipt">确认收货</el-button>
                </div>
            </div>
        </el-drawer>
    </div>
</template>

<script setup lang="ts">
const { proxy } = getCurrentInstance() as any;
import { getLogisticsTraceDetailList } from '@/api/group/product'
import print from '@/views/group/investDepartment/commodityManage/components/print.vue'
import { hmProductsPcList } from '@/api/group/productOutbound/index'
import { categoryList } from '@/api/system/supplierAddProducts';
import { type Action } from 'element-plus'
import { handleEditPermission } from '@/utils/auditStatusFilter'
import { loginSupplierByRoleList } from '@/api/group/supplier/index'
import visaExemption from '@/assets/images/visaExemption.png'
import { removeInvalidNodes } from '@/utils/index'
import Qs from "qs";
import { getUserList, loginDeptList, getSystemList } from '@/api/group/qualityControl'
import AddForm from './addform/index.vue'
import { auditStatusButtonById } from '@/utils/statusButton'
import { againStock, editFive, editFour, editOff, editSevens, editTen, editTwo, outSupplier, reAuditSecond, skipProduct, submitAudit } from '@/api/group/product/index'
import { queryOperationDeptList } from '@/api/group/productSelectionPricing'
import mailed from '@/views/group/investDepartment/commodityManage/components/mailed.vue'
import qualificationsDialog from '@/views/group/investDepartment/commodityManage/components/qualificationsDialog.vue'
import anchorSelection from '@/views/group/investDepartment/commodityManage/components/anchorSelection.vue'
import noContractApprovalDialog from '@/views/group/investDepartment/commodityManage/components/noContractApprovalDialog.vue'
import mechanismPriceChange from '@/views/group/investDepartment/commodityManage/components/mechanismPriceChange.vue'
import useUserStore from '@/store/modules/user';
const commodityManage = ref()
const columnData = ref()
const props = { label: 'categoryName', value: 'categoryId', multiple: true }
const { hm_product_status } = toRefs<any>(proxy?.useDict('hm_product_status'));
const buttonLoading = ref(false);
const activeTab = ref('qualityControl');
const queryFormRef = ref();
const isAddDrawer = ref(false)
const showSearch = ref(true);
const loading = ref(false);
const queryParams = ref({
    pageNum: 1,
    pageSize: 10,
    content: '',
    categoryIdList: [],
    supplierName: '',
    auditStatus: '',
    styleName: '',
    recruiterUserId: '',
    recruiterDeptId: '',
    recruiterDeptIds: '',
    createStartTime: '',
    createEndTime: '',
    contractStatus: '',
    examineStatus: '',
    coreIdList: '',
    liveTypeList: '',
    pricingStartTime: '',
    pricingEndTime: '',
    selectionStartTime: '',
    selectionEndTime: '',
    skip: '',
    auditType: '',
    brandName: '',
})
const ids = ref<Array<any>>([]);
// 选中商品状态
const selectedStatus = ref<Array<any>>([])
const tableData = ref([])
const tableTotal = ref(0)
const categoryProps = ref([])
const supplierNameOptions = ref<any[]>([])
const deptList = ref<{ deptId: string; deptName: string; }[]>([])
const recruiterList = ref<{ userId: string; nickName: string; }[]>([])
const AddFormTitle = ref('')
const AddFormId = ref('')
const disabledName = ref('')
const supplierLoading = ref(true)
const supplierNameDate = ref<any>({
    pageNum: 1,
    pageSize: 10,
    supplierName: ''
})
const supplierQueryLoading = ref(false)
const supplierNametotal = ref()
const anchorList = ref<{ deptName: string; deptId: string }[]>([]);
// 时间
const startTime = ref()
// 核价通过时间
const pricingTime = ref()
// 选品时间
const selectionTime = ref()
// 合同状态
const contractList = ref([
    { label: '待上传', value: '0' },
    { label: '已上传/无需上传', value: '1' },
])
// 审批状态
const examineList = ref([
    { label: '待送审', value: '6' },
    { label: '初审中', value: '7' },
    { label: '初审驳回', value: '8' },
    { label: '复审中', value: '11' },
    { label: '复审驳回', value: '12' },
    { label: '复审通过', value: '13' },
    { label: '入库审批中', value: '16' },
    { label: '入库驳回', value: '17' },
    { label: '入库通过', value: '18' },
    { label: '变价审批中', value: '19' },
    { label: '变价驳回', value: '20' },
    { label: '变价通过', value: '21' },
    { label: '无合同审批中', value: '22' },
    { label: '无合同驳回', value: '14' },
    { label: '无合同通过', value: '15' },
])
// 直播类型
const liveTypeList = ref([
    { label: '平播', value: '平播' },
    { label: '打榜', value: '打榜' },
    { label: '活动', value: '活动' },
    { label: '大货', value: '大货' },
])
// 审批类型
const auditTypeList = ref([
    { label: '核价初审', value: '0' },
    { label: '核价复审', value: '1' },
    { label: '无合同审批', value: '2' },
    { label: '入库审批', value: '3' },
    { label: '变价审批', value: '4' },
])
// 跳过物流
const skipList = ref([
    { label: '是', value: '1' },
    { label: '否', value: '0' },
])
// 部门类型
const departmentTypeList = ref()
// 打印ref
const printRef = ref()
// 变更主播数据
const isChangeList = ref()
// 变价审核数据
const mechanismPriceChangeList = ref()
// 弹窗操作商品id
const productId = ref()
// 已邮寄显隐
const expressDeliveryDialogVisible = ref(false)
// 主播选品显隐
const anchorSelectionVisible = ref(false)
// 发起送审显隐
const qualificationsFlag = ref(false)
// 无合同审批显隐
const noContractApprovalFlag = ref(false)
// 变价审批显隐
const mechanismPriceChangeVisible = ref(false)
//物流名称
const shippingCompany = ref()
//物流单号
const trackingNumber = ref()
//物流轨迹
const logisticsTraceDetailList = ref<any>([])
//当前商品状态
const confirmReceiptStatus = ref(false)
//当前选中ID
const currentId = ref()
// 物流信息显隐
const logisticsInfoVisible = ref(false)
/**
 * 获取部门类型
 */
const getdeptType = async () => {
    const res = await getSystemList({ parentId: '1861962988832542721' })
    const data = res.data.filter((item: any) => item.deptName !== '研发部')
    departmentTypeList.value = data
}
/** 商品状态流转 */
const handleChangeStatus = async (row: any, statusName: string) => {
    switch (statusName) {
        case '已邮寄':
            expressDeliveryDialogVisible.value = true
            productId.value = row.id
            break;
        case '跳过':
            ElMessageBox.confirm('跳过邮寄状态的商品将被视为已实际收到样品，请确保您已收到样品~', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                callback: async (action: Action) => {
                    if (action == 'confirm') {
                        await skipProduct({ id: row.id })
                        proxy?.$modal.msgSuccess('跳过邮寄成功');
                        await getList()
                    }
                },
            })
            break;
        case '已到样':
            await editTwo({ id: row.id })
            proxy?.$modal.msgSuccess('商品到样确认成功');
            await getList()
            break;
        case '确认收货':
            await editFour(Qs.stringify({ ids: [row.id] }, { arrayFormat: 'repeat' }))
            proxy?.$modal.msgSuccess('商品确认收货成功');
            await getList()
            break;
        case '上架':
            await editFive(Qs.stringify({ ids: [row.id] }, { arrayFormat: 'repeat' }));
            proxy?.$modal.msgSuccess('商品上架成功');
            await getList()
            break;
        case '下架':
            await editOff(Qs.stringify({ ids: [row.id] }, { arrayFormat: 'repeat' }));
            proxy?.$modal.msgSuccess('商品下架成功');
            await getList()
            break;
        case '退还':
            ElMessageBox.confirm('确认将选中商品退还供应商？', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                callback: async (action: Action) => {
                    if (action == 'confirm') {
                        await outSupplier({ ids: [row.id] })
                        proxy?.$modal.msgSuccess('商品退还成功');
                        await getList()
                    }
                },
            })
            break;
        case '主播选品':
            isChangeList.value = undefined
            anchorSelectionVisible.value = true
            productId.value = row.id
            break;
        case '打印条码':
            const data = setPrintData(row)
            printRef.value.int(data)
            break;
        case '变更主播':
            productId.value = row.id
            isChangeList.value = {
                coreName: row.coreName,
                coreId: row.coreDeptId,
                liveType: row.liveType
            }
            anchorSelectionVisible.value = true
            break;
        case '发起初审':
            const { deptName } = useUserStore();
            if (deptName != '食品部' && deptName != '鞋帽部' && deptName != '百货部' && deptName != '酒茶部' && deptName != '箱包部' && deptName != '服装部') {
                qualificationsFlag.value = true
                productId.value = [row.id]
            } else {
                ElMessageBox.confirm('是否确认发起核价初审审批？', '提示', {
                    confirmButtonText: '确认',
                    cancelButtonText: '取消',
                    callback: async (action: Action) => {
                        if (action == 'confirm') {
                            await editSevens({ ids: [row.id] });
                            proxy?.$modal.msgSuccess('商品送审成功');
                            await getList()
                        }
                    },
                })
            }
            break;
        case '价格复审':
            ElMessageBox.confirm('是否确认重新发起核价复审审批？', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                callback: async (action: Action) => {
                    if (action == 'confirm') {
                        await reAuditSecond({ id: row.id });
                        proxy?.$modal.msgSuccess('商品送审成功');
                        await getList()
                    }
                },
            })
            break;
        case '无合同审批':
            noContractApprovalFlag.value = true
            productId.value = row.id
            break;
        case '入库':
            // 无合同驳回时
            if (row.auditStatus == 14) {
                if (row.sellStatus == "已签署") {
                    ElMessageBox.confirm('是否确认发起入库审批？', '提示', {
                        confirmButtonText: '确认',
                        cancelButtonText: '取消',
                        callback: async (action: Action) => {
                            if (action == 'confirm') {
                                await submitAudit({ productId: row.id, type: 'PRODUCT_STOCK_AUDIT' })
                                proxy?.$modal.msgSuccess('产品入库中');
                                await getList()
                            }
                        },
                    })
                } else {
                    proxy?.$modal.msgError('无法入库,当前商品暂无供销合同，请关注供销合同上传或无合同审批进展...');
                }
            } else {
                ElMessageBox.confirm('是否确认发起入库审批？', '提示', {
                    confirmButtonText: '确认',
                    cancelButtonText: '取消',
                    callback: async (action: Action) => {
                        if (action == 'confirm') {
                            await editTen(Qs.stringify({ ids: [row.id] }, { arrayFormat: 'repeat' }));
                            proxy?.$modal.msgSuccess('产品入库中');
                            await getList()
                        }
                    },
                })
            }
            break;
        case '重新入库':
            ElMessageBox.confirm('是否确认重新发起入库审批？', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                callback: async (action: Action) => {
                    if (action == 'confirm') {
                        await againStock({ id: row.id });
                        proxy?.$modal.msgSuccess('产品重新入库中');
                        await getList()
                    }
                },
            })
            break;
        case '变价审核':
            mechanismPriceChangeVisible.value = true
            mechanismPriceChangeList.value = {
                id: row.id,
                styleName: row.styleName,
                specs: row.specs,
                sellingPoints: row.sellingPoints,
                productImage: row.productImage,
                tax: row.tax,
                hmMechanismsList: row.hmMechanismsList
            }
            break;
        case '物流信息':
            //清理初始化数据
            logisticsTraceDetailList.value = []
            //获取物流信息
            console.log('参数传递', row.trackingNumber, row.logisticsType)
            shippingCompany.value = row.shippingCompany
            trackingNumber.value = row.trackingNumber
            const res = await getLogisticsTraceDetailList({ orderNo: row.trackingNumber, cpCode: row.logisticsType })
            if (res.data) {
                logisticsTraceDetailList.value = JSON.parse(res.data.trajectory).reverse()
                if (['2', 2].includes(row.auditStatus)) {
                    confirmReceiptStatus.value = true
                } else {
                    confirmReceiptStatus.value = false
                }
            }
            logisticsInfoVisible.value = true
            currentId.value = row.id
            console.log('物流信息', logisticsTraceDetailList.value)
            break;
        default:
            break;
    }
}
// 处理打印数据
const setPrintData = (arr: any) => {
    const barcodePrintData: any = []
    // 商品名
    let styleName =
        arr.styleName.length > 18
            ? arr.styleName.substr(0, 18)
            : arr.styleName;
    // 上架时间
    let listingTime = arr.shoppingTime ? "上架时间:" + arr.shoppingTime : '上架时间:';
    // 招商员姓名
    let recruiter = '招商:' + arr.recruiter
    // 规格/材质
    const specs = arr.specs.length > 192 ? arr.specs.substring(0, 192) : arr.specs
    // 卖点
    let sellingPoint = "卖点:" + arr.sellingPoints;
    let specsing =
        "规格/材质:" + specs;
    const arrs: Array<string> = [];
    if (arr.hmMechanismsList.length > 0) {
        arr.hmMechanismsList.forEach((items: any, ins: number) => {
            if (items.cooperationMode) {
                const obj = {
                    title: ins == 0 ? '机制一:' : ins == 1 ? '机制二:' : '机制三:',
                    number: items.cooperationMode == '分佣' ? `${items.price || 0.00}` : `${items.costPrice || 0.00}`,
                    commission: items.cooperationMode == '分佣' ? `${items.commission || 0.00}%` : '',
                    brokerage: items.cooperationMode == '分佣' ? `+${items.brokerage || 0.00}%` : '',
                    liveStreamingMechanism: ins == 0 ? items.liveStreamingMechanism || '' : items.liveStreamingMechanism.substring(0, 8) || ''
                }
                arrs.push(obj.title)
                arrs.push(obj.number)
                arrs.push(obj.commission)
                arrs.push(obj.brokerage)
                arrs.push(obj.liveStreamingMechanism)
            }
        })
    }
    const obj = {
        InitDrawingBoardParam: {
            width: 70,
            height: 80,
            rotate: 0,
            path: "ZT001.ttf",
            verticalShift: 0,
            HorizontalShift: 0,
        },
        elements: [
            {
                type: "barCode",
                json: {
                    x: 7.5,
                    y: 1.0,
                    width: 55,
                    height: 10,
                    value: arr.id,
                    codeType: 20,
                    rotate: 0,
                    fontSize: 3.2,
                    textHeight: 3,
                    textPosition: 0,
                }
            },
            // 商品名
            {
                type: "text",
                json: {
                    x: 4.8,
                    y: 10.6,
                    width: 61.0,
                    height: 4.3,
                    value: styleName + '(商品名)',
                    fontSize: 4,
                    rotate: 0,
                    lineMode: 6,
                    lineSpace: 0,
                    letterSpace: 0,
                    textAlignHorizonral: 1,
                    textAlignVertical: 1,
                }
            },
            // 上架时间
            {
                type: "text",
                json: {
                    x: 1.0,
                    y: 15.8,
                    width: 33.9,
                    height: 2.4,
                    value: listingTime,
                    fontSize: 2.3,
                    rotate: 0,
                    lineMode: 2,
                    lineSpace: 0,
                    letterSpace: 0,
                    textAlignHorizonral: 0,
                    textAlignVertical: 1,
                }
            },
            // 招商员信息
            {
                type: "text",
                json: {
                    x: 42.6,
                    y: 15.8,
                    width: 26.8,
                    height: 2.4,
                    value: recruiter,
                    fontSize: 2.3,
                    rotate: 0,
                    lineMode: 2,
                    lineSpace: 0,
                    letterSpace: 0,
                    textAlignHorizonral: 1,
                    textAlignVertical: 1,
                }
            },
            // 规格材质
            {
                type: "text",
                json: {
                    x: 1.0,
                    y: 32.0,
                    width: 66.1,
                    height: 2.4,
                    value: specsing,
                    fontSize: 2.3,
                    rotate: 0,
                    lineMode: 2,
                    lineSpace: 0,
                    letterSpace: 0,
                    textAlignHorizonral: 0,
                    textAlignVertical: 1,
                }
            },
            // 卖点
            {
                type: "text",
                json: {
                    x: 1.0,
                    y: 53.0,
                    width: 66.1,
                    height: 2.4,
                    value: sellingPoint,
                    fontSize: 2.3,
                    rotate: 0,
                    lineMode: 2,
                    lineSpace: 0,
                    letterSpace: 0,
                    textAlignHorizonral: 0,
                    textAlignVertical: 1,
                }
            },

        ]
    }
    arrs.forEach((item, index) => {
        if (index == 0 || index == 5 || index == 10) {
            obj.elements.push(
                {
                    type: "text",
                    json: {
                        x: 1.0,
                        y: index == 0 ? 19.1 : index == 5 ? 22.5 : 25.9,
                        width: 8.4,
                        height: 2.4,
                        value: item,
                        fontSize: 2.3,
                        rotate: 0,
                        lineMode: 2,
                        lineSpace: 0,
                        letterSpace: 0,
                        textAlignHorizonral: 0,
                        textAlignVertical: 1,
                    }
                }
            )
        }
        if (index == 1 || index == 6 || index == 11) {
            obj.elements.push(
                {
                    type: "text",
                    json: {
                        x: 10.0,
                        y: index == 1 ? 19.1 : index == 6 ? 22.5 : 25.9,
                        width: 13,
                        height: 2.4,
                        value: item,
                        fontSize: 2.3,
                        rotate: 0,
                        lineMode: 2,
                        lineSpace: 0,
                        letterSpace: 0,
                        textAlignHorizonral: 0,
                        textAlignVertical: 1,
                    }
                }
            )
        }
        if (index == 2 || index == 7 || index == 12) {
            obj.elements.push(
                {
                    type: "text",
                    json: {
                        x: 23.2,
                        y: index == 2 ? 19.1 : index == 7 ? 22.5 : 25.9,
                        width: 7.3,
                        height: 2.4,
                        value: item,
                        fontSize: 2.3,
                        rotate: 0,
                        lineMode: 2,
                        lineSpace: 0,
                        letterSpace: 0,
                        textAlignHorizonral: 0,
                        textAlignVertical: 1,
                    }
                }
            )
        }
        if (index == 3 || index == 8 || index == 13) {
            obj.elements.push(
                {
                    type: "text",
                    json: {
                        x: 30.5,
                        y: index == 3 ? 19.1 : index == 8 ? 22.5 : 25.9,
                        width: 7.3,
                        height: 2.4,
                        value: item,
                        fontSize: 2.3,
                        rotate: 0,
                        lineMode: 2,
                        lineSpace: 0,
                        letterSpace: 0,
                        textAlignHorizonral: 0,
                        textAlignVertical: 1,
                    }
                }
            )
        }
        if (index == 4 || index == 9 || index == 14) {
            obj.elements.push(
                {
                    type: "text",
                    json: {
                        x: 37.8,
                        y: index == 4 ? 19.1 : index == 9 ? 22.5 : 25.9,
                        width: 30,
                        height: 2.4,
                        value: item,
                        fontSize: 2.3,
                        rotate: 0,
                        lineMode: 2,
                        lineSpace: 0,
                        letterSpace: 0,
                        textAlignHorizonral: 0,
                        textAlignVertical: 1,
                    }
                }
            )
        }
    })
    barcodePrintData.push(obj)
    return barcodePrintData
}
/** 填写单号成功 */
const expressDeliverySubmit = async () => {
    expressDeliveryDialogVisible.value = false
    await getList()
}
/** 送审成功 */
const qualificationsFlagSubmit = async () => {
    qualificationsFlag.value = false
    await getList()
}
/** 无合同审批成功 */
const noContractApprovalSubmit = async () => {
    noContractApprovalFlag.value = false
    await getList()
}
/** 退出主播选品二次确认 */
const anchorSelectionHandleClose = async () => {
    await proxy?.$modal.confirm('是否退出当前编辑页面，已编辑的信息将被清空');
    anchorSelectionVisible.value = false
}
/** 变价审核二次确认 */
const mechanismPriceChangeHandleClose = async () => {
    await proxy?.$modal.confirm('是否退出当前编辑页面，已编辑的信息将被清空');
    mechanismPriceChangeVisible.value = false
}
/** 选择主播 */
const anchorSelectionHandleChange = async () => {
    proxy?.$modal.msgSuccess('选择主播成功');
    anchorSelectionVisible.value = false
    await getList()
}
/** 变价审核关闭 */
const mechanismPriceChangeHandleChange = async () => {
    proxy?.$modal.msgSuccess('变价审核提交成功');
    mechanismPriceChangeVisible.value = false
    await getList()
}
/** 更改主播 */
const onChangeSubmit = async () => {
    proxy?.$modal.msgSuccess('主播更改成功');
    isChangeList.value = undefined
    anchorSelectionVisible.value = false
    await getList()
}
// 查询列表数据
const getList = async () => {
    try {
        loading.value = true
        const params = { ...queryParams.value, productStatus: 1, recruiterDeptId: queryParams.value.recruiterDeptIds || queryParams.value.recruiterDeptId }
        const { rows = [], total = 0 } = await hmProductsPcList(params)
        tableData.value = rows
        tableTotal.value = total
        loading.value = false
    } catch (e) {
    } finally {
        loading.value = false;
    }
}
/** 页数变化 */
const paginationChange = async () => {
    await getList();
    await proxy?.useColumnUpdate(columnData.value, queryParams.value.pageSize)
    getColmun()
}
/** 搜索按钮操作 */
const handleQuery = () => {
    queryParams.value.pageNum = 1;
    getList();
};
// 获取选品部门
const getAnchor = async () => {
    const res = await queryOperationDeptList()
    anchorList.value = res.data
}
/** 重置按钮操作 */
const resetQuery = () => {
    queryFormRef.value?.resetFields();
    recruiterList.value = []
    startTime.value = undefined
    pricingTime.value = undefined
    selectionTime.value = undefined
    queryParams.value.createStartTime = ''
    queryParams.value.createEndTime = ''
    queryParams.value.pricingStartTime = ''
    queryParams.value.pricingEndTime = ''
    queryParams.value.selectionStartTime = ''
    queryParams.value.selectionEndTime = ''
    handleClear();
    handleQuery();
};
/** 完成时间筛选 */
const pickerChange = (val: string[]) => {
    if (val) {
        queryParams.value.createStartTime = val[0]
        queryParams.value.createEndTime = val[1]
    } else {
        queryParams.value.createStartTime = ''
        queryParams.value.createEndTime = ''
    }
}
/** 核价通过时间 */
const pricingPickerChange = (val: string[]) => {
    if (val) {
        queryParams.value.pricingStartTime = val[0]
        queryParams.value.pricingEndTime = val[1]
    } else {
        queryParams.value.pricingStartTime = ''
        queryParams.value.pricingEndTime = ''
    }
}
/** 选品时间 */
const selectionPickerChange = (val: string[]) => {
    if (val) {
        queryParams.value.selectionStartTime = val[0]
        queryParams.value.selectionEndTime = val[1]
    } else {
        queryParams.value.selectionStartTime = ''
        queryParams.value.selectionEndTime = ''
    }
}
// 筛选类目change事件
const handleChange = (val: [string, string, string, string]) => {
}
/**
 * 部门筛选
 */
const departmentTypeChange = async (parentId: string) => {
    if (parentId) {
        queryParams.value.recruiterDeptIds = ''
        queryParams.value.recruiterUserId = ''
        const res = await getSystemList({ parentId })
        deptList.value = res.data
        recruiterList.value = []
    } else {
        deptList.value = []
        recruiterList.value = []
        queryParams.value.recruiterDeptIds = ''
        queryParams.value.recruiterUserId = ''
    }
}
// 根据招商部获取招商员
const deptChange = async (event: string) => {
    if (event) {
        const res = await getUserList({ deptId: event })
        recruiterList.value = res.rows
        queryParams.value.recruiterUserId = ''
    } else {
        recruiterList.value = []
        queryParams.value.recruiterUserId = ''
    }
    queryParams.value.recruiterUserId = ''
}

/** 多选框选中数据 */
const handleSelectionChange = (selection: any) => {
    ids.value = selection.map((item: any) => item.id);
    selectedStatus.value = selection.map((item: any) => item.auditStatus);
};
/** 商品流转操作 */
const handleOperate = async (title: string) => {
    if (title == '确认收货') {
        const falg = selectedStatus.value.every((item: any) => item == 2)
        if (!falg) {
            ElMessageBox.confirm('您所选中的商品状态不一致，无法进行批量操作，请优先筛选商品状态', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
            })
        } else {
            ElMessageBox.confirm('即将对您选中的' + ids.value.length + '件商品进行批量确认收货操作，请确认是否继续', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                callback: async (action: Action) => {
                    if (action == 'confirm') {
                        buttonLoading.value = true;
                        try {
                            await editFour(Qs.stringify({ ids: [ids.value] }, { arrayFormat: 'repeat' }))
                            proxy?.$modal.msgSuccess('商品批量确认收货成功');
                            await getList()
                            ids.value = []
                            selectedStatus.value = []
                            buttonLoading.value = false;
                        } catch (error) {
                            buttonLoading.value = false;
                        }
                    }
                },
            })
        }
    } else if (title == '上架') {
        const falg = selectedStatus.value.every((item: any) => item == 4 || item == '-1')
        if (!falg) {
            ElMessageBox.confirm('您所选中的商品状态不一致，无法进行批量操作，请优先筛选商品状态', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
            })
        } else {
            ElMessageBox.confirm('即将对您选中的' + ids.value.length + '件商品进行批量上架操作，请确认是否继续', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                callback: async (action: Action) => {
                    if (action == 'confirm') {
                        buttonLoading.value = true;
                        try {
                            await editFive(Qs.stringify({ ids: [ids.value] }, { arrayFormat: 'repeat' }))
                            proxy?.$modal.msgSuccess('商品批量上架成功');
                            await getList()
                            ids.value = []
                            selectedStatus.value = []
                            buttonLoading.value = false;
                        } catch {
                            buttonLoading.value = false;
                        }
                    }
                },
            })
        }
    } else if (title == '发起初审') {
        const falg = selectedStatus.value.every((item: any) => item == 6 || item == 8 || item == 9 || item == 10)
        if (!falg) {
            ElMessageBox.confirm('您所选中的商品状态不一致，无法进行批量操作，请优先筛选商品状态', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
            })
        } else {
            ElMessageBox.confirm('即将对您选中的' + ids.value.length + '件商品进行批量发起初审操作，请确认是否继续', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                callback: async (action: Action) => {
                    if (action == 'confirm') {
                        buttonLoading.value = true;
                        const { deptName } = useUserStore();
                        if (deptName != '食品部' && deptName != '鞋帽部' && deptName != '百货部' && deptName != '酒茶部' && deptName != '箱包部' && deptName != '服装部') {
                            buttonLoading.value = false;
                            qualificationsFlag.value = true
                            productId.value = ids.value
                        } else {
                            try {
                                await editSevens({ ids: ids.value });
                                proxy?.$modal.msgSuccess('商品批量送审成功');
                                await getList()
                                ids.value = []
                                selectedStatus.value = []
                                buttonLoading.value = false;
                            } catch {
                                buttonLoading.value = false;
                            }
                        }
                    }
                },
            })
        }
    } else if (title == '入库') {
        const falg = selectedStatus.value.every((item: any) => item == 14 || item == 15)
        if (!falg) {
            ElMessageBox.confirm('您所选中的商品状态不一致，无法进行批量操作，请优先筛选商品状态', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
            })
        } else {
            ElMessageBox.confirm('即将对您选中的' + ids.value.length + '件商品进行批量入库操作，请确认是否继续', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                callback: async (action: Action) => {
                    if (action == 'confirm') {
                        buttonLoading.value = true;
                        try {
                            await editTen(Qs.stringify({ ids: [ids.value] }, { arrayFormat: 'repeat' }));
                            proxy?.$modal.msgSuccess('商品批量入库成功');
                            await getList()
                            ids.value = []
                            selectedStatus.value = []
                            buttonLoading.value = false;
                        } catch {
                            buttonLoading.value = false;
                        }
                    }
                },
            })
        }
    } else if (title == '下架') {
        const falg = selectedStatus.value.every((item: any) => (item >= 5 && item <= 17) || item == 22)
        if (!falg) {
            ElMessageBox.confirm('您所选中的商品状态不一致，无法进行批量操作，请优先筛选商品状态', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
            })
        } else {
            ElMessageBox.confirm('即将对您选中的' + ids.value.length + '件商品进行批量下架操作，请确认是否继续', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                callback: async (action: Action) => {
                    if (action == 'confirm') {
                        buttonLoading.value = true;
                        try {
                            await editOff(Qs.stringify({ ids: [ids.value] }, { arrayFormat: 'repeat' }));
                            proxy?.$modal.msgSuccess('商品批量下架成功');
                            await getList()
                            ids.value = []
                            selectedStatus.value = []
                            buttonLoading.value = false;
                        } catch {
                            buttonLoading.value = false;
                        }
                    }
                },
            })
        }
    }
}
// 直播机制反显
const computedMechanism = (row: any, numbers: string) => {
    if (row) {
        const price = row.price ? row.price : '-'
        const commission = row.commission ? row.commission + '%' : '-'
        const brokerage = row.brokerage ? row.brokerage + '%' : '-'
        const liveStreamingMechanism = row.liveStreamingMechanism ? row.liveStreamingMechanism : '-'
        const costPrice = row.costPrice ? row.costPrice : '-'
        if (row.cooperationMode) {
            if (row.cooperationMode == '分佣') {
                return '机制' + numbers + ': ' + '售价:' + price + ' 佣金:' + commission + ' 补充佣金:' + brokerage + ' 机制:' + liveStreamingMechanism + ' 成本:' + costPrice
            } else {
                return '机制' + numbers + ': ' + '成本:' + costPrice + ' 机制:' + liveStreamingMechanism
            }
        }
    }
}
/** 查看商品详情 */
const handleInfo = (row: any, title: string) => {
    isAddDrawer.value = true;
    AddFormTitle.value = title
    AddFormId.value = row.id
    if (title == '编辑商品') {
        switch (handleEditPermission(row.auditStatus)) {
            // 都不可编辑
            case '0':
                disabledName.value = ''
                break;
            // 都可编辑
            case '1':
                disabledName.value = 'all'
                break;
            // 编辑商品信息，除了机制
            case '3':
                disabledName.value = 'noMechanism'
                break;
            // 只可编辑机制 规格/材质 卖点 商品图 对接群名
            case '4':
                disabledName.value = 'rejectStatus'
                break;
            // 只可编辑规格/材质 卖点 商品图 对接群名
            case '5':
                disabledName.value = 'alwaysEdit'
                break;
            default:
                break;
        }
    } else {
        disabledName.value = ''
    }
};
/** 新增商品 */
const addProduct = (title: string) => {
    isAddDrawer.value = true;
    AddFormTitle.value = title
    disabledName.value = 'add'
}
/** 单选商品下架 */
// const productDelisting = async (type, row) => {
//     if (type == 'one') {
//         ids.value = [row]
//     }
//     offShelfDialogVisible.value = true
// }
// 入库条件反显
const qualificationReview = (data: any, key: string) => {
    if (key === '入库状态') {
        if (data == 4 || data == 0) {
            return '?'
        } else if (data == 2) {
            return '√'
        } else if (data == 1) {
            return '×'
        }
    } else if (key === '核价初审') {
        if (!data?.length) {
            return '?'
        } else if (data?.length) {
            // 审核通过
            if (data[0].firstStatus == 11) {
                return '√'
            } else if (data[0].firstStatus == 8 || data[0].firstStatus == 9 || data[0].firstStatus == 10) {
                return '×'
            } else if (data[0].firstStatus == 7) {
                return '?'
            }
        }
    } else if (key === '核价复审') {
        if (!data?.length) {
            return '?'
        } else if (data?.length) {
            // 审核通过
            if (data[0].auditStatus == 13) {
                return '√'
            } else if (data[0].auditStatus == 12) {
                return '×'
            } else if (data[0].auditStatus == 11) {
                return '?'
            }
        }
    }
}
// 弹框关闭
const handleClose = async () => {
    if (AddFormTitle.value == '查看详情') {
        isAddDrawer.value = false
    } else {
        await proxy?.$modal.confirm('是否退出当前编辑页面，已编辑的商品信息将被清空');
        isAddDrawer.value = false
    }
}
// 商品提交回调函数
const AddFormSubmit = () => {
    isAddDrawer.value = false
    getList()
}
/** 获取colmun */
const getColmun = async () => {
    const columnDatas = await proxy?.useColumn('招商部商品管理')
    commodityManage.value = columnDatas.columnCustom
    columnData.value = columnDatas
    queryParams.value.pageSize = columnDatas.columnPageSize || 10
}
/** 拖拽事件 */
const dragEnd = async (newWidth: number, oldWidth: number, column: any, event: MouseEvent) => {
    columnData.value.columnCustom.map((item: any) => {
        if (item.prop == column.property) {
            item.width = newWidth
        }
    })
    await proxy?.useColumnUpdate(columnData.value, queryParams.value.pageSize)
}
onMounted(async () => {
    await getColmun()
    await getList()
    getdeptType()
    getCategoryList()
    getDeptLists()
    getAnchor();
})
// 查询类目
const getCategoryList = async () => {
    const { data = [] } = await categoryList({})
    categoryProps.value = removeInvalidNodes(data, 'categoryStatus');
}

// 获取供应商列表
const getHmSupplierList = async () => {
    supplierLoading.value = true
    const res = await loginSupplierByRoleList(supplierNameDate.value)
    const reshandle = res.rows.map((item: any) => (
        {
            label: item.supplierName,
            value: item.supplierName
        }
    ))
    supplierNameOptions.value.push(...reshandle)
    supplierNametotal.value = res.total
    supplierLoading.value = false
}
/** select懒加载 */
const selectLoad = async () => {
    if (supplierNameOptions.value.length < supplierNametotal.value) {
        supplierNameDate.value.pageNum++;
        getHmSupplierList()
    }
}
/** 远程搜索 */
const searchQuery = async (query: string) => {
    supplierQueryLoading.value = true
    supplierNameOptions.value = []
    supplierNameDate.value.pageNum = 1;
    supplierNameDate.value.pageSize = 10
    supplierNameDate.value.supplierName = query
    await getHmSupplierList()
    supplierQueryLoading.value = false
}
/** 清空供应商 */
const handleClear = () => {
    supplierNameDate.value.supplierName = ''
    supplierNameOptions.value = []
    supplierNameDate.value.pageNum = 1;
    supplierNameDate.value.pageSize = 10
    getHmSupplierList()
}
// 获取招商部
const getDeptLists = async () => {
    const res = await loginDeptList()
    deptList.value = res.data
}

//状态转换
const statusFormat = (status: string) => {
    switch (status) {
        case "WAIT_ACCEPT":
            return "待揽收";
        case "ACCEPT":
            return "已揽件";
        case "TRANSPORT":
            return "运输中";
        case "DELIVERING":
            return "派件中";
        case "AGENT_SIGN":
            return "已代签收";
        case "SIGN":
            return "已签收";
        case "FAILED":
            return "包裹异常";
        default:
            return "未知状态";
    }
}
//时间格式转换
function formatTimestamp(timestamp: number): string {
    const date = new Date(timestamp); // 将时间戳转为 Date 对象

    // 获取各个时间部分
    const year = date.getFullYear(); // 获取年份
    const month = String(date.getMonth() + 1).padStart(2, '0'); // 获取月份（注意：月份从0开始，所以加1）
    const day = String(date.getDate()).padStart(2, '0'); // 获取日期
    const hours = String(date.getHours()).padStart(2, '0'); // 获取小时
    const minutes = String(date.getMinutes()).padStart(2, '0'); // 获取分钟
    const seconds = String(date.getSeconds()).padStart(2, '0'); // 获取秒数

    // 格式化并返回
    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}

//手机号匹配
function highlightPhoneNumbers(text: any) {
    // 正则表达式匹配手机号（中国常见手机号格式）
    const phoneRegex = /\b(\d{11})\b/g;

    // 使用 replace 方法，将匹配到的手机号替换为带有 red 样式的 span
    return text.replace(phoneRegex, (match: any) => {
        return `<span style="color: red; cursor: pointer;" @click="handlePhoneClick('${match}')">${match}</span>`;
    });
}

//关闭物流弹窗
const closeLogistics = () => {
    logisticsInfoVisible.value = false
}

//弹窗中的确认收货
const handleReceipt = async () => {
    console.log('当前选中ID', currentId.value)
    await editFour(Qs.stringify({ ids: [currentId.value] }, { arrayFormat: 'repeat' }))
    proxy?.$modal.msgSuccess('商品确认收货成功');
    logisticsInfoVisible.value = false
    await getList()
}

//状态二次处理
const statusFormat2 = (status: any, number: number, row: any) => {
    // 待接收的商品去掉无合同审批
    if (row.receiveStatus == 0 && row.auditStatus == '13') {
        return ['下架', '变更主播', '打印条码']
    } else {
        if (!number) {
            //过滤掉物流信息
            return status.filter((item: any) => item !== "物流信息");  // 示例：去除所有“物流信息”元素
        }
        return status;
    }
}



</script>

<style lang="scss" scoped>
.visaExemption {
    width: 14px;
}

.supplierName_text {
    overflow: hidden;
    overflow-wrap: break-word;
    text-overflow: ellipsis;
    line-height: 1;
}

.circular {
    display: inline;
    height: 30px;
    width: 30px;
    animation: loading-rotate 2s linear infinite;
}

.path {
    animation: loading-dash 1.5s ease-in-out infinite;
    stroke-dasharray: 90, 150;
    stroke-dashoffset: 0;
    stroke-width: 2;
    stroke: var(--el-color-primary);
    stroke-linecap: round;
}

.supplierSelect {
    :deep(.el-popper) {
        left: 0 !important;
        top: 34px !important;
        z-index: 7000 !important;
        width: 100% !important;
    }
}

.supplierName {
    display: flex;
    align-items: center;
    justify-content: center;

    .el-image {
        width: 16px;
        height: 16px;
    }

}

.supplierSelect_icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.el-select-loading__tips {
    color: #606266;
    font-size: 14px;
}

:deep(.el-tabs__content) {
    overflow: visible !important;
}

.flex {
    display: flex;
    align-items: center;
    justify-content: center;
}

.el-select-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: initial;
    pointer-events: none;
    color: var(--el-color-info);
    font-size: 12px;

    &__icon {
        font-size: 16px;
        animation: rotate 1.5s linear infinite;
    }

    &__tips {
        margin-left: 6px;
    }

    @keyframes rotate {
        from {
            transform: rotate(0deg);
        }

        to {
            transform: rotate(360deg);
        }
    }
}

.logisticsContent {
    width: 100%;
    height: 100%;
    padding: 30px 30px 0 30px;
}

.custom-icon {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background-color: white;
    /* 设置蓝色背景 */
    border: 1px #B0B0B0 solid;
}

.custom-icon.active {
    background-color: #1890FF;
    /* 激活状态时为蓝色实心 */
    border: none;
    /* 移除边框 */
}

.submitFooter {
    width: 100%;
    height: 50px;
    margin-top: 50px;
    display: flex;
    justify-content: right;
    align-items: center;
    margin-bottom: 30px;
}
</style>
